package com.crr.controller;

import com.crr.bean.Order;
import com.crr.common.bean.ResultBean;
import com.crr.common.controller.BaseController;
import com.crr.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "订单")
@RequestMapping("/v1")
public class OrderController extends BaseController {
    @Autowired
    OrderService orderService;

    @ApiOperation("抢购")
    @GetMapping("/order")
    public ResultBean save(int userId, int goodsId) {
        String save = orderService.save(userId, goodsId);
        return  success("抢购结果",save) ;
    }

    @ApiOperation("秒杀订单详情")
    @GetMapping("/order/detail")
    public ResultBean getOrder(String orderNum) {
        Order order = orderService.getOrder(orderNum);
        return success("订单详情",order);
    }
}
